<?php
/**
 * User: 五哥派
 * Date: 2024/7/1
 * Tel(同WX): 17335592719
 */
namespace app\api\model\store;

use app\api\model\Base;

class Cart extends Base{

    protected $name = 'store_cart';

    protected $autoWriteTimestamp = true;

    // 定义追加的字段
    protected $append = ['origin_image'];

    // 定义获取追加字段的方法
    public function getOriginImageAttr($value, $data)
    {
        return $data['image'];
    }

    public function getImageAttr($value){
        return $this->prefixImageUrl($value);
    }

    public function sum($where){
        return self::where($where)->sum('num');
    }

    public function sku() {
        return $this->hasOne(GoodsSku::class, "id",  "sku_id");
    }

    public function getList($where=array(), $field = '', array $with = []){
        return self::field($field)->with($with)->where($where)->order($this->order)->select();
    }


}